---
description: "Reference for Nitric's Dart library - Retrieves the value from a version of a secret."
---

# Dart - secret.version.access()

<Note>
  This is reference documentation for the Nitric Dart SDK. To learn about
  Secrets in Nitric start with the [Secrets docs](/secrets).
</Note>

Retrieves the value from a version of a secret.

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("apiKey").allow([
  SecretPermission.access,
]);

final keyValue = await keyRef.latest().access();
```

## Examples

### Access the latest version of a secret

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("apiKey").allow([
  SecretPermission.access,
]);

final keyValue = await keyRef.latest().access();
```

### Access a specific version of a secret

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("apiKey").allow([
  SecretPermission.access,
]);

final keyValue = await keyRef.version("the-version-id").access();
```
